package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {
    @GetMapping("/v1/user/login1")
    @ResponseBody
    public String login1(String username,String password){
        System.out.println(username +"---"+password);
        return "登陆成功1";
    }

    @PostMapping("/v1/user/login2")
    @ResponseBody
    public String login2(UserLoginDTO userLoginDTO){
        System.out.println(userLoginDTO);
        return "登陆成功2";
    }

    @GetMapping("/bmi/{height}/{weight}")
    @ResponseBody
    public String bmi(@PathVariable Double height,@PathVariable Double weight) {
        double r = weight / (height * height);
        if (r < 18.5) {
            return "过轻";
        } else if (r < 25) {
            return "正常";
        } else if (r < 28) {
            return "过重";
        } else {
            return "肥胖";
        }
    }
}
